package com.aramis.mydytt.ui.user

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.aramis.mydytt.R
import com.aramis.mydytt.ui.base.BaseFragment
import com.aramis.mydytt.ui.user.act.UserFavoriteActivity
import com.facebook.drawee.view.SimpleDraweeView

/**
 * Description: MainUserFragment
 * 用户中心fragment
 * @author lizhidan
 * Created: 2021/6/4
 */
class MainUserFragment : BaseFragment() {
    private val adapter = MainUserAdapter()

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        val view = inflater.inflate(R.layout.fragment_main_user, container, false)
        initView(view)
        initData()
        return view
    }

    private fun initView(view: View) {
        val avatarView = view.findViewById<SimpleDraweeView>(R.id.image_user_avatar)
        avatarView.setActualImageResource(R.drawable.ic_avatar_default)
        val functionListView: RecyclerView = view.findViewById(R.id.list_user_frg)
        functionListView.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
        functionListView.adapter = adapter
        adapter.onItemClickListener = {
            when (it) {
                0 -> UserFavoriteActivity.start(requireContext(), UserFavoriteActivity.STYLE_FAVORITE)
                1 -> UserFavoriteActivity.start(requireContext(), UserFavoriteActivity.STYLE_DOWNLOADED)
            }
        }
    }

    private fun initData() {

    }
}